package com.easystudy.controller;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.easystudy.video.error.ReturnValue;
import com.easystudy.video.service.VideoService;

@RestController
public class TestController {
	@Autowired
	private VideoService videoService;
	
	@GetMapping("/publish")
	public ReturnValue<String> publish(@RequestParam(name="boxId", defaultValue = "5ab1e946c3c711ee997394e6f745cd96") String boxId,
									   @RequestParam(name="deviceId", defaultValue = "001") String deviceId,
									   @RequestParam(name="url", defaultValue = "rtmp://192.168.50.150/live/1") String url) {
		return videoService.publish(UUID.randomUUID().toString().replace("-", ""), boxId, deviceId, url);
	}
	
	@GetMapping("/cancel")
	public ReturnValue<String> cancel(@RequestParam(name="boxId", defaultValue = "5ab1e946c3c711ee997394e6f745cd96") String boxId,
									  @RequestParam(name="deviceId", defaultValue = "001") String deviceId) {
		return videoService.cancel(UUID.randomUUID().toString().replace("-", ""), boxId, deviceId);
	}
}
